﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Davsha.App.Actions
{
    public class ActionParameterCollection : List<ActionParameter>
    {
        public string this[string name]
        {
            get
            {
                return this.First(p => p.Name.Equals(name)).Value;
            }
        }

        public bool TryGetParameterValue(string name, out string value)
        {
            ActionParameter parameter = this.FirstOrDefault(p => p.Name.Equals(name));
            if (parameter == null)
            {
                value = null;
                return false;
            }
            value = parameter.Value;
            return true;
        }

        public string TryGetParameterValue(string name)
        {
            ActionParameter parameter = this.FirstOrDefault(p => p.Name.Equals(name));
            if (parameter == null)
            {
                return null;
            }
            return parameter.Value;
        }
    }
}
